<template>
  <div class="login">
    <el-image src="../../../public/static/image/index1.jpg"></el-image>
    <div class="loginPart">
      <h1 class="word">人员注册</h1>
          <el-divider />
      <el-form
        action="login"
        method="post"
        :model="ruleForm"
        :rules="rules"
        ref="ruleForm"
        class="demo-ruleForm">

        <el-form-item prop="username" class="inputElement">
          <el-input
            v-model="ruleForm.username"
            placeholder="请输入您的用户名"
            prefix-icon="Avatar"
          ></el-input>
        </el-form-item>

        <el-form-item prop="job" class="inputElement">
          <el-input
            v-model="ruleForm.job"
            placeholder="请输入您的工作"
            prefix-icon="Avatar"
          ></el-input>
        </el-form-item>

        <el-form-item prop="age" class="inputElement">
          <el-input
            v-model="ruleForm.age"
            placeholder="请输入您的年龄"
            prefix-icon="Avatar"
          ></el-input>
        </el-form-item>

        <el-form-item prop="name" class="inputElement">
          <el-input
            v-model="ruleForm.name"
            placeholder="请输入真实姓名"
            clearable
            prefix-icon="Avatar"
          >
          </el-input>
        </el-form-item>
        <el-form-item prop="password" class="inputElement">
          <el-input
            v-model="ruleForm.password"
            placeholder="请输入密码"
            clearable
            type="password"
            prefix-icon="Lock"
            show-password
          >
          </el-input>
        </el-form-item>
        <el-form-item prop="repassword" class="inputElement">
          <el-input
            v-model="repassword"
            placeholder="请确认密码"
            clearable
            type="password"
            prefix-icon="Lock"
            show-password
          >
          </el-input>
        </el-form-item>
        
        <span style="color: red">{{ msg }}</span>
        <el-form-item>
          <el-button color="#3c9566" plain  @click="loginf()"
            ><span style="display: inline-block; width: 142px"></span>点击注册<span
              style="display: inline-block; width: 142px"
            ></span
          ></el-button>
          
          
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  name: "index",
  data() {
    return {
      ruleForm: {
        username: "",
        name:"",
        password: "",
        job:"",
        age:"",
      },
      repassword:"",
      rules: {
        username: [
          {
            required: true,
            message: "用户名不能为空",
            trigger: "blur",
          },
        ],
        password: [
          {
            required: true,
            message: "密码不能为空",
            trigger: "blur",
          },
        ],
        captcha: [
          {
            required: true,
            message: "验证码不能为空",
            trigger: "blur",
          },
          {
            min: 4,
            max: 4,
            message: "长度为4个字符",
            trigger: "blur",
          },
        ],
      },
      // url: "http://localhost:8080/login/captcha",
      msg: "",
    };
  },
  methods: {
    // submit() {
    //     this.$axios({
    //           method:"post",
    //           url:"http://localhost:8080/login/index",
    //           data:this.$qs.stringify(this.ruleForm),
    //        		withCredentials: true,
    //           crossDomain:true
    //         }).then((res) => {
    //           if (res.data.code == 1) {
    //             this.$router.push({name:"main",params:res.data.data})
    //           }else{
    //             this.msg = res.data.msg;
    //           } 
    //         });
    // },

    // change() {
      
    //   // this.$axios({
    //   //         method:"get",
    //   //         url:"http://localhost:8080/login/captcha?d=" + new Date().getTime(),
    //   //       }).then(res => {
    //   //          console.log((res.data.msg));
    //   //       });
    //    this.url = "http://localhost:8080/login/captcha?d=" + new Date().getTime()
    // },
    loginf() {
      console.log(this.ruleForm);
      if(this.ruleForm.password==this.repassword){
        var _this=this;
        this.$axios({
             method:"post",
             url:"http://localhost:8080/login/regi",
             data:
            _this.$qs.stringify(_this.ruleForm),
          }).then(res => {
            console.log(res.data);
          }).catch((err) => {
            console.log("err");
          });
      }else{
        alert("两次密码不一致")
      }
          
        }
  },
  
        

};
</script>

<style scoped>
.loginPart {
  position: absolute;
  /*定位方式绝对定位absolute*/
  top: 50%;
  left: 50%;
  /*顶和高同时设置50%实现的是同时水平垂直居中效果*/
  transform: translate(-50%, -50%);
  /*实现块元素百分比下居中*/
  width: 450px;
  padding: 40px;
  background: rgba(0, 0, 0, 0.5);
  /*背景颜色为黑色，透明度为0.8*/
  box-sizing: border-box;
  /*box-sizing设置盒子模型的解析模式为怪异盒模型，
    将border和padding划归到width范围内*/
  box-shadow: 0px 15px 25px rgba(1, 0, 0, 0.5);
  /*边框阴影  水平阴影0 垂直阴影15px 模糊25px 颜色黑色透明度0.5*/
  /* border-radius: 15px; */
  /*边框圆角，四个角均为15px*/
}
.loginPart h1 {
  margin: 0 0 30px;
  padding: 0;
  color: #fff;
  text-align: center;
  /*文字居中*/
}
.loginPart .inputbox {
  position: relative;
}
.loginPart .inputElement input {
  width: 100%;
  padding: 10px 0;
  font-size: 16px;
  color: #fff;
  letter-spacing: 1px;
  /*字符间的间距1px*/
  margin-bottom: 30px;
  border: none;
  border-bottom: 1px solid #fff;
  outline: none;
  /*outline用于绘制元素周围的线
    outline：none在这里用途是将输入框的边框的线条使其消失*/
  background: transparent;
  /*背景颜色为透明*/
}

button {
  margin-top: 10px;
}

.login {
  width: 100%;
  height: 100%;
  padding: 0px;
}
</style>
